package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class TweenActivity extends AppCompatActivity {

    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tween);
        imageView = findViewById(R.id.tween_iv);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 定义alpha动画
                Animation animAlpha = AnimationUtils.loadAnimation(TweenActivity.this, R.anim.alpha_tween_anim);
                animAlpha.setFillAfter(true);
                // 定义旋转动画
                Animation animRotate = AnimationUtils.loadAnimation(TweenActivity.this, R.anim.rotate_tween_anim);
                animRotate.setFillAfter(true);
                // 定义缩放动画
                Animation animScale = AnimationUtils.loadAnimation(TweenActivity.this, R.anim.scale_tween_anim);
                animScale.setFillAfter(true);
                // 定义平移动画
                Animation animTranslate = AnimationUtils.loadAnimation(TweenActivity.this, R.anim.translate_tween_anim);
                animTranslate.setFillAfter(true);
                // 定义Alpha和缩放动画
                Animation animAlphaScale = AnimationUtils.loadAnimation(TweenActivity.this, R.anim.alpha_scale_tween_anim);
                animAlphaScale.setFillAfter(true);
                imageView.startAnimation(animAlphaScale);
            }
        });
    }
}